var oldObjArrayPendingCheckout = new Array();
var setRowObjArrayCheckout = new Array();
//////////////Start CheckOutPending Page ////////////////
function searchAll_checkoutpendingPage(value,e){
	if (e.keyCode == 13 && !e.ctrlKey) {
		getReservationRoomManageMentCheckoutPending("textSearch",value)
		$("#SearchAll_checkoutpendingPage").val("");
	}
}
function getReservationRoomManageMentCheckoutPending(data,valueSearch){
	clearData();
	waitingDialog({});
	var searchName = $("#SearchAll_checkoutpendingPage").val();
	if($("#RowpagerCheckOutPendingListRoomManageMent").val() == null){
		getCurrentTabData().linePendingCheckout = 10;
	}else{
		getCurrentTabData().linePendingCheckout = $("#RowpagerCheckOutPendingListRoomManageMent").val();
	}
	if($("#pagerCheckOutPendingListRoomManageMent").val() == null){
		var pagePointer = 1; 
	}else{
		if(valueSearch!=""&&valueSearch!=undefined){
			//var pagePointer = 1;
			var pagePointer = valueSearch; 
		}else{
			var pagePointer = 1;
			getCurrentTabData().pagerNumber = 1;
		}
	}
	var offfset = (getCurrentTabData().linePendingCheckout*pagePointer)-getCurrentTabData().linePendingCheckout;
	var dataOld =  $("#typeCheckReservation").val();
	if(data=="CheckOutPendingListRoomManageMent"){
		if(pagePointer>1){
			var link = "/reservationService?func=getReservationAllCheckoutPending&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
			var linkSet = "/reservationService?func=getReservationAllCheckoutPending&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
			getCurrentTabData().linkSet = linkSet;
			simpleservice(link,null,showDataResRoomManageMentSetCountPendingCheckout,getCurrentTabData().linePendingCheckout);
		}else{
			getCurrentTabData().beforePagePendingCheckout = ""; 
			getCurrentTabData().beforeSubPagePendingCheckout = "";
			var link = "/reservationService?func=getReservationAllCheckoutPending&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
			simpleservice(link,null,showDataResRoomManageMentCheckoutPending,data);
		}
	}else if(data=="G"||data == "textSearch"){
		if(data == "textSearch")
			data = $("#typeCheckReservation").val();
		getCurrentTabData().typeReservationPendingCheckout = data;
		typeReservationPendingCheckoutFunction(dataOld,offfset,pagePointer,data,searchName);
	}else if(data=="S"||data == "textSearch"){
		if(data == "textSearch")
			data = $("#typeCheckReservation").val();
		getCurrentTabData().typeReservationPendingCheckout = data;
		typeReservationPendingCheckoutFunction(dataOld,offfset,pagePointer,data,searchName);
	}else if(data=="A"||data == "textSearch"){
		if(data == "textSearch")
			data = $("#typeCheckReservation").val();
		getCurrentTabData().typeReservationPendingCheckout= data;
		typeReservationPendingCheckoutFunction(dataOld,offfset,pagePointer,data,searchName);
	}else if(data == "textSearch"){
		showDataResRoomManageMentCheckoutPending(data,"textSearch");
	}
}
function showDataResRoomManageMentCheckoutPending(data,output){
	// set for pager
	getCurrentTabData().tablePager = "tablepagingPendingCheckout";
	getCurrentTabData().pagerNumberField = "pagerCheckOutPendingListRoomManageMent";
	getCurrentTabData().functionGetData = "getReservationRoomManageMentCheckoutPending";
	getCurrentTabData().pageName = "CheckOutPendingListRoomManageMent";
	getCurrentTabData().pageNavPosition = "pageNavPositionPendingCheckout";
	getCurrentTabData().trCheck = "trPendingcheckout";
	if(getCurrentTabData().typeReservationPendingCheckout!=undefined){
		$('#typeCheckReservation option[value='+getCurrentTabData().typeReservationPendingCheckout+']').attr('selected', 'selected');
	}
	if(data.trim()=="[]"){
		var textDataEmpty = '<tr clearTr="checkoutpendingReservation" >'+
		'<td colspan="100%" style="text-align:center;" >'+
		dataEmpty+
		'</td>'+
		'</tr>';
		textRoomCheckOutPending = textDataEmpty;
		$("[clearTr=checkoutpendingReservation]").remove();
		$("#CheckOutPendingListRoomManageMent_Id_Tr").replaceWith("<tr id=CheckOutPendingListRoomManageMent_Id_Tr ></tr>"+textRoomCheckOutPending);
		textRoomCheckOutPending = '';
	}else{
		$("[clearTr=checkoutpendingReservation]").remove();
		var objArray = new Array();
		if((data=="textSearch"||data=="G"||data=="S"||data=="A"||data=="reservationType_A"||data=="Checked-out Rooms"||data=="Checked-in Rooms")&&data!="dateSearch"){
			objArray = oldObjArrayPendingCheckout;
			objArray = objArray[0];
		}else{
			objArray = JSON.parse(data);
			oldObjArrayPendingCheckout = objArray;
			objArray = objArray[0];
		}
		var numberSet = getCurrentTabData().beforePagePendingCheckout; 
		var numberSubSet = getCurrentTabData().beforeSubPagePendingCheckout;
		sortIdRoommanagement(objArray);
		textRoomCheckOutPendingPrint = '';
		var checkBgColor = 0;
		var countGroup = 0;
		var OldGroupId =0;
		var valueSearch = $("#SearchAll_checkoutpendingPage").val();
		var typeReservation = $("#typeCheckReservation").val();
		var firstSelect = "";
		var emailPic = '<img src=../images/components/roommanagement/email.png alt=Note height=15 width=20>';
		var printPci = '<img src=../images/components/roommanagement/print.png alt=Note height=15 width=20>';
		for(var i =0;i<objArray.length;i++){
			if(objArray[i].name!=""&&objArray[i].name!=undefined){
				var nameReservation = objArray[i].name.split(" ");
			}else{
				var nameReservation = "";
			}
			var Objtitle = objArray[i].reservationTitle;
			var ObjgroupId = objArray[i].groupId;
			var ObjId = objArray[i].id;
			/*var checkContinue = checkedFilter(output,valueSearch,nameReservation,firstSelect,Objtitle,ObjgroupId,typeReservation,ObjId);
			if(checkContinue==1){
				continue;
			}*/
			//	OldGroupId = objArray[i].groupIdString;
			if(objArray[i].groupId!="0"){
				if(objArray[i].subList!=undefined){
					var setDateFormat = new Date(objArray[i].date);
					var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
					groupId = objArray[i].groupIdString;
					var splitResIdInGroup = objArray[i].resList.split(",");
					var textSubRes = "";
					var textSubResPrint = "";
					var checkBgColorG =0;
					var StatusResInGroup = "";
					for(var subRes = 0;subRes<objArray[i].subList.length;subRes++){
						var DescriptionSubRes = "";
						if(objArray[i].subList[subRes].description!=undefined&&objArray[i].subList[subRes].description!=""){
							DescriptionSubRes = objArray[i].subList[subRes].description;
						}else{
							DescriptionSubRes = "";
						}
						var setDateFormatRes = new Date(objArray[i].subList[subRes].date);
						var setFateFormatCheckoutRes = setDateFormatRes.addDate(objArray[i].subList[subRes].span);
						var ShowNameGuest = "";
						/// Name Empty
						if(objArray[i].subList[subRes].name!=undefined){
							ShowNameGuest = objArray[i].subList[subRes].name
						}
						///
						if(objArray[i].subList[subRes].reservationTitle=="Reserved Rooms"){
							StatusResInGroup = statusResv;
						}else if(objArray[i].subList[subRes].reservationTitle=="Checked-out Rooms"){
							StatusResInGroup = statusCheckOut;
						}else if(objArray[i].subList[subRes].reservationTitle=="Temp Rooms"){
							StatusResInGroup = statusTempResv;
						}else if(objArray[i].subList[subRes].reservationTitle=="Cancel Reservation"){
							StatusResInGroup = statusCancelCheckin;
						}else{
							StatusResInGroup = statusCheckin;
						}
						if(checkBgColorG==0){
							statusRecord = 'dataRecordBot';
							checkBgColorG = 1;
						}else{
							statusRecord = 'dataRecordBot';
							checkBgColorG =0;
						}
						var showDisplayGuestname = "";
						if(ShowNameGuest==""){
							showDisplayGuestname = '<tr clearTr=checkoutpendingReservation class="'+statusRecord+'" onclick="if(linkClick==true)noGuestName();"  id="btnEditS" >';
						}else{
							showDisplayGuestname = '<tr clearTr=checkoutpendingReservation class="'+statusRecord+'" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].subList[subRes].id+')"  id="btnEditS" >';
						}
						var runnumberSub = "";
						if(getCurrentTabData().beforePagePendingCheckout!=undefined&&getCurrentTabData().beforePagePendingCheckout!=""){
							runnumberSub = (numberSet+1)+"."+(subRes+1);
						}else{
							runnumberSub = (i+1)+"."+(subRes+1);
						}
							textSubRes += showDisplayGuestname+
							'<td colspan="2" class="spanDataCenter">'+
							runnumberSub+
							'</td>'+
							'<td class="spanDataCenter">' +
								'<span>'+objArray[i].subList[subRes].id+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span class="guestName" >'+ShowNameGuest+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+setDateFormatRes.getFormatedString()+'-'+setFateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].subList[subRes].span+'</span>'+
							'</td>'+
							'<td class="spanDataCenter"> '+
								'<span>'+objArray[i].subList[subRes].roomTypeName+'('+objArray[i].subList[subRes].roomName+')'+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">' +
								'<span>'+adult+'('+objArray[i].subList[subRes].adult+') - '+child+'('+objArray[i].subList[subRes].child+')'+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								StatusResInGroup+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+toCurrencyString((objArray[i].subList[subRes].defaultCherge))+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span><div class="fongwordwarp" >'+DescriptionSubRes+'</div></span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
							'</td>'+
							'</tr>';
							textSubResPrint += '<tr clearTr="checkoutpendingReservation" class="dataRecord" onclick="if(linkClick&&ShowNameGuest!="") CallEditReservedPageWithLoadElement(id,'+objArray[i].subList[subRes].id+')"  id="btnEditS" >'+
							'<td colspan="2" class="spanDataCenter">'+
							runnumberSub+
							'</td>'+
							'<td class="spanDataCenter">' +
								'<span>'+objArray[i].subList[subRes].id+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span class="guestName" >'+ShowNameGuest+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+setDateFormatRes.getFormatedString()+'-'+setFateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].subList[subRes].span+'</span>'+
							'</td>'+
							'<td class="spanDataCenter"> '+
								'<span>'+objArray[i].subList[subRes].roomTypeName+'('+objArray[i].subList[subRes].roomName+')'+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">' +
								'<span>'+adult+'('+objArray[i].subList[subRes].adult+') - '+child+'('+objArray[i].subList[subRes].child+')'+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								StatusResInGroup+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span>'+toCurrencyString((objArray[i].subList[subRes].defaultCherge))+'</span>'+
							'</td>'+
							'<td class="spanDataCenter">'+
								'<span><div class="fongwordwarp" >'+DescriptionSubRes+'</div></span>'+
							'</td>'+
							'</tr>';
					}
					///Check StatusGroup
					var obj = objArray[i].subList;
					showStatusResInGroup = checkStatusReservationGroup(obj);
					///
					if(getCurrentTabData().beforePagePendingCheckout!=undefined&&getCurrentTabData().beforePagePendingCheckout!=""){
						numberSet = numberSet+1;
						number = numberSet;
					}else{
						number = (i+1);
					}
						textRoomCheckOutPending += '<tr clearTr=checkoutpendingReservation class="dataRecordGroup" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].groupIdString+')"  id="btnEditG" >'+
						'<td class="spanDataMagin">'+
						number+'('+objArray[i].resList.split(",").length+')'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>G'+objArray[i].groupIdString+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="ownerName" >'+objArray[i].name+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
						'<span>'+showStatusResInGroup+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span><div class="fongwordwarp" >'+objArray[i].description+'</div></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
						'</td>'+
					'</tr>'+textSubRes;
						
						textRoomCheckOutPendingPrint += '<tr clearTr=checkoutpendingReservation class="dataRecordGroup" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].groupIdString+')"  id="btnEditG" >'+
						'<td class="spanDataMagin">'+
						number+'('+objArray[i].resList.split(",").length+')'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>G'+objArray[i].groupIdString+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="ownerName" >'+objArray[i].name+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
						'<span>'+showStatusResInGroup+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span><div class="fongwordwarp" >'+objArray[i].description+'</div></span>'+
						'</td>'+
					'</tr>'+textSubResPrint;
						checkBgColor =1;
						textSubRes = "";
				}else{
					var DescriptionSubRes = "";
					if(objArray[i].description!=undefined&&objArray[i].description!=""){
						DescriptionSubRes = objArray[i].description;
					}else{
						DescriptionSubRes = "";
					}
					var setDateFormatRes = new Date(objArray[i].date);
					var setFateFormatCheckoutRes = setDateFormatRes.addDate(objArray[i].span);
					var ShowNameGuest = "";
					/// Name Empty
					if(objArray[i].name!=undefined){
						ShowNameGuest = objArray[i].name
					}
					///
					if(objArray[i].reservationTitle=="Reserved Rooms"){
						StatusResInGroup = statusResv;
					}else if(objArray[i].reservationTitle=="Checked-out Rooms"){
						StatusResInGroup = statusCheckOut;
					}else if(objArray[i].reservationTitle=="Temp Rooms"){
						StatusResInGroup = statusTempResv;
					}else if(objArray[i].reservationTitle=="Cancel Reservation"){
						StatusResInGroup = statusCancelCheckin;
					}else{
						StatusResInGroup = statusCheckin;
					}
					if(checkBgColorG==0){
						statusRecord = 'dataRecordBot';
						checkBgColorG = 1;
					}else{
						statusRecord = 'dataRecordBot';
						checkBgColorG =0;
					}
					var showDisplayGuestname = "";
					if(ShowNameGuest==""){
						showDisplayGuestname = '<tr clearTr=checkoutpendingReservation class="'+statusRecord+'"   id="btnEditS" >';
					}else{
						showDisplayGuestname = '<tr clearTr=checkoutpendingReservation class="'+statusRecord+'" onclick="if(linkClick) CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')"  id="btnEditS" >';
					}
					if(getCurrentTabData().beforePagePendingCheckout!=undefined&&getCurrentTabData().beforePagePendingCheckout!=""){
						runnumberSub = (numberSet)+"."+(numberSubSet);
						numberSubSet = numberSubSet+1;
					}else{
						runnumberSub = (i+1)+"."+(subRes+1);
					}
					textRoomCheckOutPending += showDisplayGuestname+
						'<td colspan="2" class="spanDataCenter">'+
						runnumberSub+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+objArray[i].id+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="guestName" >'+ShowNameGuest+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormatRes.getFormatedString()+'-'+setFateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
							'<span>'+objArray[i].roomTypeName+'('+objArray[i].roomName+')'+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+adult+'('+objArray[i].adult+') - '+child+'('+objArray[i].child+')'+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							StatusResInGroup+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+toCurrencyString((objArray[i].defaultCherge))+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span><div class="fongwordwarp" >'+DescriptionSubRes+'</div></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
						'</td>'+
						'</tr>';
					textRoomCheckOutPendingPrint += '<tr clearTr="checkoutpendingReservation" class="dataRecord" onclick="if(linkClick&&ShowNameGuest!="") CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')"  id="btnEditS" >'+
						'<td colspan="2" class="spanDataCenter">'+
						runnumberSub+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+objArray[i].id+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="guestName" >'+ShowNameGuest+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormatRes.getFormatedString()+'-'+setFateFormatCheckoutRes.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
							'<span>'+objArray[i].roomTypeName+'('+objArray[i].roomName+')'+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+adult+'('+objArray[i].adult+') - '+child+'('+objArray[i].child+')'+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							StatusResInGroup+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+toCurrencyString((objArray[i].defaultCherge))+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span><div class="fongwordwarp" >'+DescriptionSubRes+'</div></span>'+
						'</td>'+
						'</tr>';
				}
			}else{
				res = objArray[i].id;
				var setDateFormat = new Date(objArray[i].date);
				var setFateFormatCheckout = setDateFormat.addDate(objArray[i].span);
				getStatusResInGroup = objArray[i].reservationTitle;
				if(getStatusResInGroup=="Reserved Rooms"){
					showStatusResInGroup = statusResv;
				}else if(getStatusResInGroup=="Checked-out Rooms"){
					showStatusResInGroup = statusCheckOut;
				}else if(getStatusResInGroup=="Temp Rooms"){
					showStatusResInGroup = statusTempResv;
				}else if(getStatusResInGroup=="Cancel Reservation"){
					showStatusResInGroup = statusCancelCheckin;
				}else{
					showStatusResInGroup = statusCheckin;
				}
				if(setDateFormat.getFormatedString()!=undefined){
					if(checkBgColor==0){
						statusRecord = 'dataRecordBot';
						checkBgColor = 1;
					}else{
						statusRecord = 'dataRecordBot';
						checkBgColor =0;
					}
					if(getCurrentTabData().beforePagePendingCheckout!=undefined&&getCurrentTabData().beforePagePendingCheckout!=""){
						numberSet = numberSet+1;
						number = numberSet;
					}else{
						number = (i+1);
					}
						textRoomCheckOutPending += '<tr clearTr=checkoutpendingReservation class="'+statusRecord+'" onclick="if(linkClick){ CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')}" id="btnEditS" >'+
						'<td class="spanDataMagin">'+
						number+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+objArray[i].id+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="guestName" >'+objArray[i].name+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
							'<span>'+objArray[i].roomTypeName+'('+objArray[i].roomName+')'+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
						'<span>'+adult+'('+objArray[i].adult+') - '+child+'('+objArray[i].child+')'+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+showStatusResInGroup+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+toCurrencyString((objArray[i].defaultCherge))+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
						'<span><div class="fongwordwarp" >'+objArray[i].description+'</div></span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
						'</td>'+
					'</tr>';
						textRoomCheckOutPendingPrint += '<tr clearTr=checkoutpendingReservation class="dataRecord" onclick="if(linkClick){ CallEditReservedPageWithLoadElement(id,'+objArray[i].id+')}" id="btnEditS" >'+
						'<td class="spanDataMagin">'+
						number+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span></span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
							'<span>'+objArray[i].id+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span class="guestName" >'+objArray[i].name+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+setDateFormat.getFormatedString()+'-'+setFateFormatCheckout.getFormatedString()+' / '+objArray[i].span+'</span>'+
						'</td>'+
						'<td class="spanDataCenter"> '+
							'<span>'+objArray[i].roomTypeName+'('+objArray[i].roomName+')'+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">' +
						'<span>'+adult+'('+objArray[i].adult+') - '+child+'('+objArray[i].child+')'+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
							'<span>'+showStatusResInGroup+'</span>'+
						'</td>'+	
						'<td class="spanDataCenter">'+
							'<span>'+toCurrencyString((objArray[i].defaultCherge))+'</span>'+
						'</td>'+
						'<td class="spanDataCenter">'+
						'<span><div class="fongwordwarp" >'+objArray[i].description+'</div></span>'+
						'</td>'+
					'</tr>';
				}
			}
		}
		if(textRoomCheckOutPending==""){
			var textDataEmpty = '<tr clearTr="checkoutpendingReservation" >'+
			'<td colspan="100%" style="text-align:center;" >'+
			dataEmpty+
			'</td>'+
			'</tr>';
			textRoomCheckOutPending = textDataEmpty;
		}
		$("#CheckOutPendingListRoomManageMent_Id_Tr").replaceWith("<tr id=CheckOutPendingListRoomManageMent_Id_Tr ></tr>"+textRoomCheckOutPending);
		textRoomCheckOutPending = "";
		textPrint = textRoomCheckOutPendingPrint;
		}
		closeWaitingDialog();
		showDataResRoomManageMentSetPagePendingCheckout(data,getCurrentTabData().linePendingCheckout);
}

function showDataResRoomManageMentSetPagePendingCheckout(data,output){
	$("[clearTr*=checkoutpendingReservationPage]").remove();
	objArray = JSON.parse(data);
	objArray = objArray[1];
	var textRoomPendingCheckoutSetpage = "";
	for(var i =0;i<objArray.length;i++){
		var textSubRes = "";
		if(objArray[i].groupId!="0"){
			var statusRecord = "";
			for(var subRes = 0;subRes<objArray[i].subList.length;subRes++){
				textSubRes += '<tr clearTr=checkoutpendingReservationPage  ><td></td></tr>';
			}
			textRoomPendingCheckoutSetpage += '<tr clearTr=checkoutpendingReservationPage class="trPendingcheckout"><td></td></tr>'+textSubRes;
		}else{
			textRoomPendingCheckoutSetpage += '<tr clearTr=checkoutpendingReservationPage ><td></td></tr>';
		}
	}
	$("[name = CheckOutPendingListRoomManageMent_Id_Tr2]").replaceWith("<tr name=CheckOutPendingListRoomManageMent_Id_Tr2></tr>"+textRoomPendingCheckoutSetpage);
	
	textRoomPendingCheckoutSetpage = "";
	textSubRes = "";
	showPager(output);
}

function showDataResRoomManageMentSetCountPendingCheckout(data,output){
	var subCount = 0;
	var recCount = 0;
	var objArray = new Array();
	if((data=="textSearch"||data=="G"||data=="S"||data=="A"||data=="reservationType_A"||data=="Checked-out Rooms"||data=="Checked-in Rooms")&&data!="dateSearch"){
		objArray = oldObjArrayPendingCheckout;
		objArrayCheck = objArray[0];
		objArray = objArray[1];
	}else{
		objArray = JSON.parse(data);
		oldObjArrayPendingCheckout = objArray;
		objArrayCheck = objArray[0];
		objArray = objArray[1];
	}
	setRowObjArrayCheckout = objArray;
	sortIdRoommanagement(objArray);
	sortIdRoommanagement(objArrayCheck);
	for(var i =0;i<objArray.length;i++){
		if(objArray[i].groupId!="0"){
			if(objArray[i].subList!=undefined){
				if(objArrayCheck[objArrayCheck.length-1].groupId==objArray[i].groupId){
					recCount = (i+1);
					subCount = objArrayCheck[objArrayCheck.length-1].subList.length+1;
					break;
				}
			}else{
				if(objArrayCheck[objArrayCheck.length-1].groupId==objArray[i].groupId){
					recCount = (i+1);
					break;
				}
			}
		}else{
			if(objArrayCheck[objArrayCheck.length-1].id==objArray[i].id){
				recCount = (i+1);
				break;
			}
		}
	}
	getCurrentTabData().beforePagePendingCheckout = (recCount);
	getCurrentTabData().beforeSubPagePendingCheckout = subCount;
	simpleservice(getCurrentTabData().linkSet,null,showDataResRoomManageMentCheckoutPending,data);
}

function typeReservationPendingCheckoutFunction(dataOld,offfset,pagePointer,data,searchName){
	if(dataOld=="G"){
		if(pagePointer>1){
			var link = "/reservationService?func=getReservationAllCheckoutPendingGroup&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
			var linkSet = "/reservationService?func=getReservationAllCheckoutPendingGroup&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
			getCurrentTabData().linkSet = linkSet;
			simpleservice(link,null,showDataResRoomManageMentSetCountPendingCheckout,getCurrentTabData().linePendingCheckout);
		}else{
			getCurrentTabData().beforePagePendingCheckout = ""; 
			getCurrentTabData().beforeSubPagePendingCheckout = "";
			var link = "/reservationService?func=getReservationAllCheckoutPendingGroup&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
			simpleservice(link,null,showDataResRoomManageMentCheckoutPending,data);
		}
	}else if(dataOld=="S"){
		if(pagePointer>1){
			var link = "/reservationService?func=getReservationAllCheckoutPendingSingle&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
			var linkSet = "/reservationService?func=getReservationAllCheckoutPendingSingle&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
			getCurrentTabData().linkSet = linkSet;
			simpleservice(link,null,showDataResRoomManageMentSetCountPendingCheckout,getCurrentTabData().linePendingCheckout);
		}else{
			getCurrentTabData().beforePagePendingCheckout = ""; 
			getCurrentTabData().beforeSubPagePendingCheckout = "";
			var link = "/reservationService?func=getReservationAllCheckoutPendingSingle&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
			simpleservice(link,null,showDataResRoomManageMentCheckoutPending,data);
		}
	}else if(dataOld=="A"){
		if(pagePointer>1){
			var link = "/reservationService?func=getReservationAllCheckoutPending&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+(pagePointer-1)+"&SearchAll_checkoutPage="+searchName;
			var linkSet = "/reservationService?func=getReservationAllCheckoutPending&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
			getCurrentTabData().linkSet = linkSet;
			simpleservice(link,null,showDataResRoomManageMentSetCountPendingCheckout,getCurrentTabData().linePendingCheckout);
		}else{
			getCurrentTabData().beforePagePendingCheckout = ""; 
			getCurrentTabData().beforeSubPagePendingCheckout = "";
			var link = "/reservationService?func=getReservationAllCheckoutPending&offset="
				+offfset+"&line="+getCurrentTabData().linePendingCheckout+"&pagePointer="+pagePointer+"&SearchAll_checkoutPage="+searchName;
			simpleservice(link,null,showDataResRoomManageMentCheckoutPending,data);
		}
	}
}